﻿using System;
using System.Collections.Generic;
using Microsoft.SharePoint.Administration;
using System.Text;

namespace SPPoSh.Cmdlets.CustomObjects
{
    public class SPPoShVersionInfo
    {        
        public SPPoShVersionInfo()
        {
            SPFarm farm = SPFarm.Local;
            this.FarmVersion = farm.BuildVersion.ToString();

            SPProductVersions versions = SPProductVersions.GetProductVersions();
            List<SPServerProductInfo> infos = versions.ServerInformation;
            SPServerProductInfo prodInfo  = infos[0];
            string str = prodInfo.Products[0];
            
            SPProduct singleProductInfo = prodInfo.GetSingleProductInfo(str);
            string str2 = singleProductInfo.PatchableUnitDisplayNames[0];
            SPPatchableUnitInfo info = singleProductInfo.GetPatchableUnitInfoByDisplayName(str2)[0];

            this.ComponentVersion = info.BaseVersionOnServer(prodInfo.ServerId).ToString();
        }

        public string ComponentVersion
        { get; set; }

        public string FarmVersion
        { get; set; }
    }
}
